const path = require('path')
const htmlwebpackPlugin = require('html-webpack-plugin')
const { merge} =require('webpack-merge')
const proConfig = require('./webpack.prod')
const devConfig = require('./webpack.dev')
const commoinConfig = {
    entry: './区分生产和开发环境/index.js',
    output: {
        filename: 'index.js',
        path: path.resolve(__dirname, '../dist')
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            }
        ]
    },
    plugins: [
        new htmlwebpackPlugin(
            {
                template: './区分生产和开发环境/index.html'
            }
        )
    ],
}
module.exports = (env) => {
    const isProdection = env.production
    //根据打包模式 进行合并
    const config = isProdection ? proConfig : devConfig
    const merageConfig=merge(commoinConfig,config)
    return merageConfig
}